<?php include './application/views/common/zhs_header.php';?>

<?php include './application/views/common/zhs_usercenter_acnt.php';?>
<div class="inv_box w">
<?php include './application/views/common/zhs_usercenter_left.php';?>
  <div class="membd_right">
     <h3 class="membdrg_tit">查看信息</h3>
    <div class="mem_perbox">
<?php if($msg=='' && isset($info['id'])){?>
<form id="message_view_form">
	<div class="user_right_border">
		<div class="l">标题：</div>
		<div class="c">
			<input type="hidden" name="name" value="回复：<?php echo $info['name'];?>">
			<?php echo $info['name']; ?>
		</div>
	</div>
	<?php if($info['is_receive'] == 1){?>
	<div class="user_right_border">
		<div class="l">发送人：</div>
		<div class="c">
			<input type="hidden" name="receive_user" value="<?php echo $info['sent_user'];?>">
			<?php echo $info['sent_username']; ?>
		</div>
	</div>
	<?php }else{?>
	<div class="user_right_border">
		<div class="l">收信人：</div>
		<div class="c">
			<?php echo $info['receive_username']; ?>
		</div>
	</div>
	<?php }?>
	<div class="user_right_border">
		<div class="l">发送内容：</div>
		<div class="c" style="margin-left:110px;">
			<?php echo $info['content']; ?>
		</div>
	</div>
	<input type="button" style="cursor:pointer" class="little_button" value="返回列表" onclick="back('<?php echo isset($info['is_receive']) ? $info['is_receive']: 0;?>');"/>
</form>
<?php }else{?>

<?php }?>
</div>

<script>
<?php if($msg!=''){?>
$(function(){
	$('#dialog').dialog({
		modal:true,
		title:'系统提示',
		buttons:{"确定":function(){$(this).dialog("close");}},
		close: function() {
			location='/message/received';
		}
	}); 
	$("#msg").html("<?php echo $msg;?>");
});

<?php }?>

function back(a){
	if(a==1){
		window.location='/message/zhs_received';
	}else{
		window.location='/message/sendbox';
	}
}

function del(){
	var options = {
		url : '/message/dodel',
		//clearForm :true,
		//resetForm :true,
		//beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg==''){
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}},
					close: function() {
						location='/message/received';
					}
				}); 
				$("#msg").html("操作成功");
			}else{
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}}
				}); 
				$("#msg").html(ret.msg);
			}
		}
	};
	$("#del_form").ajaxSubmit(options);
	return false;
}

function reply(){
	var options = {
		url : '/message/dosent',
		//clearForm :true,
		//resetForm :true,
		beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg==''){
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}},
					close: function() {
						//location=ret.data.url;
						if(ret.data.url==''){
							window.location.reload();
						}else{
							window.location=ret.data.url;
						}
					}
				}); 
				$("#msg").html("操作成功");
			}else{
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}}
				}); 
				$("#msg").html(ret.msg);
			}
		}
	};
	$("#message_view_form").ajaxSubmit(options);
	return false;
}

function checkForm(){
	var a = "<?php echo $info['sent_user'];?>";
	if(a<2){
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
			close: function() {
				$("#message_view_form").resetForm();
			}
		}); 
		$("#msg").html("系统信件请不要回复");
		return false;
	}
	if($("#reply_content").val()==''){
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
			close: function() {
				$("#message_view_form").resetForm();
			}
		}); 
		$("#msg").html("回复内容为空");
		return false;
	}
	
	return true;
}
</script>
   </div>
</div> 
</div>

<?php include './application/views/common/zhs_footer.php';?>
<?php include './application/views/common/zhs_right.php';?>
    